package vn.vnu.uet.university;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import vn.vnu.uet.university.bean.DatabaseHandler;
import vn.vnu.uet.university.bean.Diem;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class Score extends DefaultActivity{
	ListView listContent;
	List<Diem> diemList = new ArrayList<Diem>();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState, R.layout.score);
		
		this.setTitle("Kết quả học tập");
		DatabaseHandler db = new DatabaseHandler(Score.this);
		
		listContent = (ListView) findViewById(R.id.listContent);

		ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> map = new HashMap<String, String>();

//		map = new HashMap<String, String>();
//		map.put("item_text", "Thăm GS.VS. Nguyễn Văn Hiệu nhân ngày Nhà giáo Việt Nam");
//		map.put("item_icon", String.valueOf(R.drawable.card_default));
//		listItem.add(map);
		
		diemList = db.getAllDiem(Token.instance().user.id);
		
		for(int i = 0; i < diemList.size(); i++) {
			map = new HashMap<String, String>();
			map.put("id", diemList.get(i).getId());
			map.put("score", Double.toString(diemList.get(i).getScore()));
			map.put("name", diemList.get(i).getName());
			listItem.add(map);
		}

		SimpleAdapter mSchedule = new SimpleAdapter(Score.this, listItem,
				R.layout.row3, new String[] { "id", "score", "name" },
				new int[] { R.id.id, R.id.score, R.id.name });
		listContent.setAdapter(mSchedule);

	}

}
